//
//  Tiezi_xiangqing_vc.m
//  ainkjj
//
//  Created by MAX on 2020/4/30.
//  Copyright © 2020 zhiyiLiu. All rights reserved.
//

static UIEdgeInsets const kInsets = {15, 16, 15, 16};
static CGSize const kAvatarSize = {38, 38};
static CGFloat const  kAvatarMarginRight = 10;
static CGFloat const  kAvatarMarginBottom = 12;
static CGFloat const  kContentMarginBotom = 12;

#import "Tiezi_xiangqing_vc.h"
#import "UIButton+WebCache.h"
#import <ZLPhotoBrowser/ZLPhotoBrowser.h>
#import "SDImageCache.h"

#import "Tiezi_pinglun_vc.h"

#import "TopicGetTopicInfo.h"

@interface Tiezi_xiangqing_vc ()<QMUITextFieldDelegate, UITextFieldDelegate>

@property(nonatomic, strong) QMUITextField *textField;
@property (nonatomic, strong)UIScrollView *sv;
@property (nonatomic, strong)CALayer *separatorLayer;

@property (nonatomic, strong)QMUIButton *btn1;
@property (nonatomic, strong)QMUIButton *btn2;
@property (nonatomic, strong)QMUIButton *btn3;
@property (nonatomic, strong)NSArray *btnArr;

@property (nonatomic, strong)CALayer *separatorLayer2;


@property (nonatomic, strong)UIImageView *head_icon_iv;

@property(nonatomic, strong) UIImageView *avatarImageView;
@property(nonatomic, strong) UILabel *nameLabel;
@property(nonatomic, strong) UILabel *timeLabel;
@property(nonatomic, strong) UILabel *contentLabel;
@property (nonatomic, strong)NSMutableArray *arrNetImages;

@property (nonatomic, copy) NSString *share_url_str;

@property (nonatomic, strong) TopicGetTopicInfoData *infoData;

@end

@implementation Tiezi_xiangqing_vc

- (void)initSubviews{
    [super initSubviews];
    
    self.separatorLayer = [CALayer qmui_separatorLayer];
    [self.view.layer addSublayer:self.separatorLayer];
    
    self.sv = [[UIScrollView alloc] init];
    [self.view addSubview:self.sv];
    {
        _avatarImageView = [[UIImageView alloc] init];
        [self.sv addSubview:self.avatarImageView];
        _avatarImageView.layer.masksToBounds = YES;
        _avatarImageView.layer.cornerRadius = 38 * 0.5;
        _nameLabel = [[UILabel alloc] qmui_initWithFont:UIFontBoldMake(16) textColor:rgb(17,17,17)];
        [self.sv addSubview:self.nameLabel];
        
        
        _timeLabel = [[UILabel alloc] qmui_initWithFont:UIFontMake(15) textColor:UIColor.qd_descriptionTextColor];
        [self.sv addSubview:self.timeLabel];
        
        _contentLabel = [[UILabel alloc] qmui_initWithFont:UIFontMake(17) textColor:UIColor.qd_mainTextColor];
        self.contentLabel.numberOfLines = 0;
        [self.sv addSubview:self.contentLabel];
        
    }
    
    _btn1 = [QMUIButton new];
    [self.view addSubview:_btn1];
    [_btn1 setTitleColor:rgb(244,110,23) forState:UIControlStateSelected];
    [_btn1 setTitleColor:rgb(153,153,153) forState:UIControlStateNormal];
    
    
    _btn2 = [QMUIButton new];
    [self.view addSubview:_btn2];
    [_btn2 setTitleColor:rgb(153,153,153) forState:UIControlStateNormal];
    _btn3 = [QMUIButton new];
    [self.view addSubview:_btn3];
    [_btn3 setTitleColor:rgb(153,153,153) forState:UIControlStateNormal];
    
    self.btnArr = @[_btn1, _btn2, _btn3];
    NSArray *imgs = @[@"praise_icon", @"comment_icon", @"share_icon"];
    for ( NSUInteger i = 0; i < self.btnArr.count ; i++) {
        QMUIButton *b = self.btnArr[i];
        //        b.tintColorAdjustsTitleAndImage = UIColor.qd_tintColor;
        b.imagePosition = QMUIButtonImagePositionLeft;
        b.spacingBetweenImageAndTitle = 8;
        [b setImage:UIImageMake(imgs[i]) forState:UIControlStateNormal];
        b.titleLabel.font = UIFontMake(16);
        b.titleLabel.textColor = rgb(244,110,23);
        
        if (i == 0) {
            [b setImage:UIImageMake(@"praise_selected_icon") forState:UIControlStateSelected];
        }
        b.tag = i;
        [b addTarget:self action:@selector(threeBtnClick:) forControlEvents:UIControlEventTouchUpInside];
    }
    
    
    self.separatorLayer2 = [CALayer qmui_separatorLayer];
    [self.view.layer addSublayer:self.separatorLayer2];
    
    
    _head_icon_iv = [UIImageView new];
    [self.view addSubview:_head_icon_iv];
    
    _textField = [[QMUITextField alloc] init];
    [_textField setReturnKeyType:UIReturnKeySend];
    self.textField.delegate = self;
    //    self.textField.maximumTextLength = 10;
    self.textField.placeholder = @"添加评论";
    self.textField.font = UIFontMake(16);
    self.textField.layer.borderColor = UIColorSeparator.CGColor;
    self.textField.layer.borderWidth = PixelOne;
    self.textField.textInsets = UIEdgeInsetsMake(0, 10, 0, 10);
    self.textField.clearButtonMode = UITextFieldViewModeAlways;
    UIImageView *tf_left_iv = [[UIImageView alloc] initWithFrame:CGRectMake(20, 0, 13, 13)];
    tf_left_iv.image = UIImageMake(@"write_review_icon");
    self.textField.leftView = tf_left_iv;
    self.textField.backgroundColor = rgb(244,244,244);
    [self.textField setLeftViewMode:UITextFieldViewModeAlways];
    [self.view addSubview:self.textField];
    
    


   
    
    [self req];
}

- (void)viewDidLayoutSubviews{
    [super viewDidLayoutSubviews];
    
    
    
    self.separatorLayer.frame = CGRectFlatMake(0, Lzy_StatusBarAndNavigationBarHeight, CGRectGetWidth(self.view.bounds), 10);
    self.sv.frame =  CGRectFlatMake(0, CGRectGetMaxY(self.separatorLayer.frame), ScreenWidth, ScreenHeight - CGRectGetMaxY(self.separatorLayer.frame) - 60 - 50 - Lzy_TabbarSafeBottomMargin);
    
    
    // 按钮布局依据 是否有图片
    CGFloat btnMaxY = CGRectGetMaxY(self.sv.frame);
    // 图片固定布局
    CGFloat ivW = (ScreenWidth - 16 - 16 - 7 * 2) / 3.0;
    CGFloat ivH = 58;
    for (NSInteger i = 0; i < self.btnArr.count; i++) {
        QMUIButton *b = self.btnArr[i];
        b.frame = CGRectMake( 16 + i * (ivW + 7), btnMaxY, ivW, ivH);
        b.titleLabel.textColor = rgb(244,110,23);
        
    }
    
    
    self.separatorLayer2.frame =  CGRectFlatMake(0, ScreenHeight - Lzy_TabbarSafeBottomMargin - 50, CGRectGetWidth(self.view.bounds), PixelOne);
    
    CGFloat head_icon_iv_w = 32;
    self.head_icon_iv.frame = CGRectFlatMake(16, CGRectGetMaxY(self.separatorLayer2.frame) + 10, head_icon_iv_w, head_icon_iv_w);
    self.head_icon_iv.layer.cornerRadius = head_icon_iv_w * 0.5;
    self.head_icon_iv.layer.masksToBounds = YES;
    
    
    self.textField.frame = CGRectFlatMake( CGRectGetMaxX(self.head_icon_iv.frame) + 10, CGRectGetMinY(self.head_icon_iv.frame), ScreenWidth - (CGRectGetMaxX(self.head_icon_iv.frame) + 10) - 16, head_icon_iv_w);
    self.textField.layer.cornerRadius = head_icon_iv_w * 0.5;

}
- (void)updateUI{
    self.title = self.infoData.name;
    
    
    // 按钮赋值
    [self.btn1 setTitle:@(self.infoData.praiseNum).stringValue forState:UIControlStateNormal];
    
    if (self.infoData.praiseStatus == 1) {
        self.btn1.selected = NO;
    }else if(self.infoData.praiseStatus == 2){
        
        
        self.btn1.selected = YES;
    }

    
    [self.btn2 setTitle:@(self.infoData.discussNum).stringValue forState:UIControlStateNormal];
    
    [self.btn3 setTitle:@(self.infoData.transmitSum).stringValue forState:UIControlStateNormal];
    
    
   
    [self.avatarImageView sd_setImageWithURL:[NSURL URLWithString:self.infoData.avatarUrl] placeholderImage:UIImageMake(@"mine_head_icon")];
    self.nameLabel.text = self.infoData.nickName;
    self.contentLabel.text = self.infoData.content;
    self.timeLabel.text = self.infoData.addTime;
    
    
    [self.head_icon_iv sd_setImageWithURL:[NSURL URLWithString:AuthSignin_model.sharedInstance.data.user_info.avatar_url] placeholderImage:UIImageMake(@"mine_head_icon")];
    
    
    {
        
        CGFloat contentLabelWidth = CGRectGetWidth(self.sv.bounds) - UIEdgeInsetsGetHorizontalValue(kInsets);
        self.avatarImageView.frame = CGRectMake(kInsets.left, kInsets.top, kAvatarSize.width, kAvatarSize.height);
        if (self.nameLabel.text.length > 0) {
            CGFloat nameLabelWidth = contentLabelWidth - CGRectGetWidth(self.avatarImageView.bounds) - kAvatarMarginRight - 44;
            CGSize nameSize = [self.nameLabel sizeThatFits:CGSizeMake(nameLabelWidth, CGFLOAT_MAX)];
            self.nameLabel.frame = CGRectFlatMake(CGRectGetMaxX(self.avatarImageView.frame) + kAvatarMarginRight, CGRectGetMinY(self.avatarImageView.frame), nameLabelWidth, nameSize.height);
        }
        
        
        
        if (self.timeLabel.text.length > 0) {
            CGSize timeSize = [self.timeLabel sizeThatFits:CGSizeMake(contentLabelWidth, CGFLOAT_MAX)];
            self.timeLabel.frame = CGRectFlatMake(CGRectGetMinX(self.nameLabel.frame), CGRectGetMaxY(self.nameLabel.frame) + 4, contentLabelWidth, timeSize.height);
        }
        if (self.contentLabel.text.length > 0) {
            CGSize contentSize = [self.contentLabel sizeThatFits:CGSizeMake(contentLabelWidth, CGFLOAT_MAX)];
            self.contentLabel.frame = CGRectFlatMake(kInsets.left, CGRectGetMaxY(self.avatarImageView.frame) + kAvatarMarginBottom, contentLabelWidth, contentSize.height);
        }
        
        
        self.arrNetImages = NSMutableArray.new;
        
        
        
        //        CGFloat contentLabelWidth = CGRectGetWidth(self.sv.bounds) - UIEdgeInsetsGetHorizontalValue(kInsets);
        CGFloat maxY = CGRectGetMaxY(self.contentLabel.frame);
        for (NSInteger i = 0; i < self.infoData.files.count; i++) {
            NSString *s = self.infoData.files[i];
            NSURL *u = [NSURL URLWithString:s];
            UIButton *btn = [[UIButton alloc] initWithFrame:CGRectMake(kInsets.left,10 + CGRectGetMaxY(self.contentLabel.frame) + i * (10 + contentLabelWidth * 165 / 343), contentLabelWidth, contentLabelWidth * 165 / 343)];
            btn.layer.masksToBounds = YES;
            btn.layer.cornerRadius = 5;
            btn.tag = i;
//            btn.qmui_borderColor = UIColor.lightGrayColor;
//            btn.qmui_borderPosition = QMUIViewBorderPositionTop | QMUIViewBorderPositionBottom | QMUIViewBorderPositionLeft |QMUIViewBorderPositionRight;
            
            [btn addTarget:self action:@selector(imgBtnClick:) forControlEvents:UIControlEventTouchUpInside];
            [self.sv addSubview:btn];
            btn.imageView.contentMode = UIViewContentModeScaleAspectFill;
            
            if ([s containsString:@".mp4"] || [s containsString:@".mov"]) {
                
                NSString *cacheKey =  [SDWebImageManager.sharedManager cacheKeyForURL:u];
                
                SDImageCache *sd_cache = SDImageCache.sharedImageCache;
                
                [SDWebImageManager.sharedManager.imageCache queryImageForKey:cacheKey options:0 context:nil cacheType:SDImageCacheTypeAll completion:^(UIImage * _Nullable image, NSData * _Nullable data, SDImageCacheType cacheType) {
                    
                    if (image) {
                        [btn setImage:image forState:UIControlStateNormal];;
                        
                    }else{
                        
                        
                        dispatch_async(dispatch_get_global_queue(0, 0), ^(void) {
                            AVURLAsset *asset = [[AVURLAsset alloc] initWithURL:u options:nil];
                            AVAssetImageGenerator *assetGen = [[AVAssetImageGenerator alloc] initWithAsset:asset];
                            
                            assetGen.appliesPreferredTrackTransform = YES;
                            CMTime time = CMTimeMakeWithSeconds(0.0, 600);
                            NSError *error = nil;
                            CMTime actualTime;
                            CGImageRef image = [assetGen copyCGImageAtTime:time actualTime:&actualTime error:&error];
                            UIImage *videoImage = [[UIImage alloc] initWithCGImage:image];
                            CGImageRelease(image);
                            [sd_cache storeImage:videoImage forKey:cacheKey completion:^{
                                
                            }];
                            dispatch_async(dispatch_get_main_queue(), ^{
                                [btn setImage:videoImage forState:UIControlStateNormal];;
                                
                                
                            });
                        });
                        
                    }
                }];
                
                
                
                
                
                UIImageView *vIv = [[UIImageView alloc] initWithFrame:CGRectMake((CGRectGetWidth(btn.frame) - 48) * 0.5, (CGRectGetHeight(btn.frame) - 48) * 0.25, 48, 48)];
                vIv.center = btn.center;
                vIv.image = UIImageMake(@"playVideo");
                [self.sv addSubview:vIv];
                
                [self.arrNetImages addObject: GetDictForPreviewPhoto(u, ZLPreviewPhotoTypeURLVideo)];
            }else{
                [btn sd_setImageWithURL:u forState:UIControlStateNormal];
                [self.arrNetImages addObject: GetDictForPreviewPhoto(u, ZLPreviewPhotoTypeURLImage)];
            }
            
            
            maxY = CGRectGetMaxY(btn.frame);
        }
        
        [self.sv setContentSize:CGSizeMake(ScreenWidth, maxY + 10)];
    }
    

    
}
- (void)req{
    NSMutableDictionary *dict = [NSMutableDictionary dictionary];
    [dict setObject:app_code forKey:@"appCode"];
    [dict setObject:AuthSignin_model.sharedInstance.data.token forKey:@"token"];
    [dict setObject:@(self.model.findTopicPageDto.ID).stringValue forKey:@"topicId"];
    
    //sender.userInteractionEnabled = NO;
    __block QMUITips *qmui_tip = [QMUITips showLoading:@"请求中..." inView:self.navigationController.view];
    
    [PPHTTPRequest req:@"java/app/topic/getTopicInfo" parameters:dict success:^(id response) {
        NSString *error_code = [NSString stringWithFormat:@"%@", response[@"error_code"]];
        if ([error_code isEqualToString:@"0"]) {
            TopicGetTopicInfo *info = [TopicGetTopicInfo mj_objectWithKeyValues:response];
            self.infoData = info.data;
            [self updateUI];
            [qmui_tip hideAnimated:YES];
        }
        else{
            
            
            [qmui_tip showError:response[@"error_msg"] hideAfterDelay:2];
            
        }
        
    } failure:^(NSError *error) {
        [qmui_tip showError:[error localizedDescription] hideAfterDelay:2];
        
    }];
}
- (void)imgBtnClick:(UIButton *)sender{
    [self previewWithIdx:sender.tag];
}
- (void)threeBtnClick:(QMUIButton *)sender{
 
    switch (sender.tag) {
        case 0:
            [self dianzan_action:sender];
            break;
        case 1:
        {
            Tiezi_pinglun_vc *vc= [[Tiezi_pinglun_vc alloc]init];
            vc.hidesBottomBarWhenPushed = YES;
            vc.model = self.infoData;
            [self.navigationController pushViewController:vc animated:YES];
        }
            break;
        case 2:
        {
            NSInteger count = MIN(30, self.infoData.content.length);
            NSString *desc = [self.infoData.content substringWithRange:NSMakeRange(0, count)];
            [Anktool fenxiangTopic:self.infoData.ID name:self.infoData.name desc:desc currentView:self.view];
        }
            break;
    }
}
- (void)dianzan_action:(QMUIButton *)sender{
    sender.userInteractionEnabled = NO;
    
    NSString *url = sender.isSelected == YES ? @"java/app/topic/repealTopicLike" : @"java/app/topic/topicLike";
    
    NSMutableDictionary *dict = [NSMutableDictionary dictionary];
    [dict setObject:app_code forKey:@"appCode"];
    [dict setObject:AuthSignin_model.sharedInstance.data.token forKey:@"token"];
    [dict setObject:@(self.infoData.ID).stringValue forKey:@"topicId"];
    
    //sender.userInteractionEnabled = NO;
    
    
    [PPHTTPRequest req:url parameters:dict success:^(id response) {
        NSString *error_code = [NSString stringWithFormat:@"%@", response[@"error_code"]];
        if ([error_code isEqualToString:@"0"]) {
            
            
            
            
            if (sender.selected) {
                self.infoData. praiseNum -=1;
            }else{
                self.infoData.praiseNum +=1;
            }
            sender.selected =  !sender.isSelected ;
            
            [self.btn1 setTitle:@(self.infoData.praiseNum).stringValue forState:UIControlStateNormal];
            
        }
        else{
            
            
            [QMUITips showError:response[@"error_msg"]];
            
        }
        sender.userInteractionEnabled = YES;
    } failure:^(NSError *error) {
        [QMUITips showError:[error localizedDescription] ];
        sender.userInteractionEnabled = YES;
    }];
}
#pragma mark - ================== 预览图片视频 ==================
- (void)previewWithIdx:(NSInteger)idx{
    
    [[self getPas] previewPhotos:self.arrNetImages index:idx hideToolBar:NO complete:^(NSArray * _Nonnull photos) {
        DLog(@"%@", photos);
    }];
}

- (ZLPhotoActionSheet *)getPas
{
    ZLPhotoActionSheet *actionSheet = [[ZLPhotoActionSheet alloc] init];
    
#pragma mark - 参数配置 optional，可直接使用 defaultPhotoConfiguration
    
    //以下参数为自定义参数，均可不设置，有默认值
    //    actionSheet.configuration.sortAscending = self.sortSegment.selectedSegmentIndex==0;
    //    actionSheet.configuration.allowSelectImage = self.selImageSwitch.isOn;
    //    actionSheet.configuration.allowSelectGif = self.selGifSwitch.isOn;
    //    actionSheet.configuration.allowSelectVideo = self.selVideoSwitch.isOn;
    //    actionSheet.configuration.allowSelectLivePhoto = self.selLivePhotoSwitch.isOn;
    //    actionSheet.configuration.allowForceTouch = self.allowForceTouchSwitch.isOn;
    //    actionSheet.configuration.allowEditImage = self.allowEditSwitch.isOn;
    //    actionSheet.configuration.allowEditVideo = self.allowEditVideoSwitch.isOn;
    //    actionSheet.configuration.allowSlideSelect = self.allowSlideSelectSwitch.isOn;
    //    actionSheet.configuration.allowMixSelect = self.mixSelectSwitch.isOn;
    //    actionSheet.configuration.allowDragSelect = self.allowDragSelectSwitch.isOn;
    //设置相册内部显示拍照按钮
    //    actionSheet.configuration.allowTakePhotoInLibrary = self.takePhotoInLibrarySwitch.isOn;
    //    //设置在内部拍照按钮上实时显示相机俘获画面
    //    actionSheet.configuration.showCaptureImageOnTakePhotoBtn = self.showCaptureImageSwitch.isOn;
    //    //设置照片最大预览数
    //    actionSheet.configuration.maxPreviewCount = self.previewTextField.text.integerValue;
    //    //设置照片最大选择数
    actionSheet.configuration.maxSelectCount = 1;
    //    actionSheet.configuration.maxVideoSelectCountInMix = 3;
    //    actionSheet.configuration.minVideoSelectCountInMix = 1;
    //设置允许选择的视频最大时长
    //    actionSheet.configuration.maxVideoDuration = self.maxVideoDurationTextField.text.integerValue;
    //    //设置照片cell弧度
    //    actionSheet.configuration.cellCornerRadio = self.cornerRadioTextField.text.floatValue;
    //单选模式是否显示选择按钮
    //    actionSheet.configuration.showSelectBtn = YES;
    //是否在选择图片后直接进入编辑界面
    //    actionSheet.configuration.editAfterSelectThumbnailImage = self.editAfterSelectImageSwitch.isOn;
    //是否保存编辑后的图片
    //    actionSheet.configuration.saveNewImageAfterEdit = NO;
    //设置编辑比例
    //    actionSheet.configuration.clipRatios = @[GetClipRatio(7, 1)];
    //是否在已选择照片上显示遮罩层
    //    actionSheet.configuration.showSelectedMask = self.maskSwitch.isOn;
    //    actionSheet.configuration.showSelectedIndex = NO;
    //颜色，状态栏样式
    //    actionSheet.configuration.previewTextColor = [UIColor brownColor];
    //    actionSheet.configuration.selectedMaskColor = [UIColor purpleColor];
    //    actionSheet.configuration.navBarColor = [UIColor orangeColor];
    //    actionSheet.configuration.navTitleColor = [UIColor blackColor];
    //    actionSheet.configuration.bottomBtnsNormalTitleColor = kRGB(80, 160, 100);
    //    actionSheet.configuration.bottomBtnsDisableBgColor = kRGB(190, 30, 90);
    //    actionSheet.configuration.bottomViewBgColor = [UIColor blackColor];
    //    actionSheet.configuration.statusBarStyle = UIStatusBarStyleDefault;
    //是否允许框架解析图片
    //    actionSheet.configuration.shouldAnialysisAsset = self.allowAnialysisAssetSwitch.isOn;
    //框架语言
    //    actionSheet.configuration.languageType = self.languageSegment.selectedSegmentIndex;
    //自定义多语言
    //    actionSheet.configuration.customLanguageKeyValue = @{@"ZLPhotoBrowserCameraText": @"没错，我就是一个相机"};
    //自定义图片
    //    actionSheet.configuration.customImageNames = @[@"zl_navBack"];
    
    //是否使用系统相机
    //    actionSheet.configuration.useSystemCamera = YES;
    //    actionSheet.configuration.sessionPreset = ZLCaptureSessionPreset1920x1080;
    //    actionSheet.configuration.exportVideoType = ZLExportVideoTypeMp4;
    //    actionSheet.configuration.allowRecordVideo = NO;
    //    actionSheet.configuration.maxRecordDuration = 5;
//#pragma mark - required
    //如果调用的方法没有传sender，则该属性必须提前赋值
    actionSheet.sender = self;
    
    
    
    return actionSheet;
}
#pragma mark - ================== tf delegate ==================

- (void)textField:(QMUITextField *)textField didPreventTextChangeInRange:(NSRange)range replacementString:(NSString *)replacementString {
    //    [QMUITips showWithText:[NSString stringWithFormat:@"文字不能超过 %@ 个字符", @(textField.maximumTextLength)] inView:self.view hideAfterDelay:2.0];
}
- (BOOL)textFieldShouldReturn:(UITextField *)textField{
    [textField resignFirstResponder];

    if (textField.text.length > 0) {
        
        NSMutableDictionary *dict = [NSMutableDictionary dictionary];
        [dict setObject:app_code forKey:@"appCode"];
        [dict setObject:AuthSignin_model.sharedInstance.data.token forKey:@"token"];
        [dict setObject:@(self.infoData.ID).stringValue forKey:@"topicId"];
        [dict setObject:textField.text forKey:@"content"];
        //sender.userInteractionEnabled = NO;
        __block QMUITips *qmui_tip = [QMUITips showLoading:@"提交中..." inView:self.navigationController.view];
        
        [PPHTTPRequest req:@"java/app/topic/pubDiscuss" parameters:dict success:^(id response) {
            NSString *error_code = [NSString stringWithFormat:@"%@", response[@"error_code"]];
            if ([error_code isEqualToString:@"0"]) {
                self.infoData.discussNum +=1;
                [self.btn2 setTitle:@(self.infoData.discussNum).stringValue forState:UIControlStateNormal];
                textField.text = @"";
                [qmui_tip showSucceed:@"评论成功" hideAfterDelay:2];
            }
            else{
                
                
                [qmui_tip showError:response[@"error_msg"] hideAfterDelay:2];
                
            }
            
        } failure:^(NSError *error) {
            [qmui_tip showError:[error localizedDescription] hideAfterDelay:2];
            
        }];
        
    }
    
    return YES;
}              // called when 'return' key pressed. return NO to ignore.

@end
